local dfx_unwinder_sources = {
  "arch_util.cpp",
  "dfx_accessors.cpp",
  "dfx_ark.cpp",
  "dfx_config.cpp",
  "dfx_elf.cpp",
  "dfx_elf_parser.cpp",
  "dfx_frame_formatter.cpp",
  "dfx_hap.cpp",
  "dfx_instr_statistic.cpp",
  "dfx_instructions.cpp",
  "dfx_map.cpp",
  "dfx_maps.cpp",
  "dfx_memory.cpp",
  "dfx_mmap.cpp",
  "dfx_ptrace.cpp",
  "dfx_regs.cpp",
  "dfx_regs_arm.cpp",
  "dfx_regs_arm64.cpp",
  "dfx_regs_riscv64.cpp",
  "dfx_regs_x86_64.cpp",
  "dfx_signal.cpp",
  "dfx_symbols.cpp",
  "thread_context.cpp",
  "unwinder.cpp",
  "unwinder_config.cpp"
}

local dfx_exidx_sources = {"arm_exidx.cpp"}

local dfx_dwarf_sources = {
  "dwarf_cfa_instructions.cpp",
  "dwarf_op.cpp",
  "dwarf_section.cpp"
}


target("unwinder")
	set_kind("$(kind)")
	add_files(dfx_unwinder_sources)
	add_files(dfx_exidx_sources)
	add_files(dfx_dwarf_sources)
	if is_arch("x86_64") then
		add_files("getcontext_x86_64.S")
	end
	add_includedirs(
		"include",
		"$(projectdir)/common/dfxlog",
		"$(projectdir)/common/dfxutil",
		"$(projectdir)/interfaces/common",
		{public=true}
	)
	add_headerfiles(
		"include/*.h",
		"$(projectdir)/common/dfxlog/*.h",
		"$(projectdir)/common/dfxutil/*.h",
		"$(projectdir)/interfaces/common/*.h"
	)
	-- add_defines("is_ohos=1","getprocpid=getpid")
	-- add_defines("is_linux=1")
	-- add_defines("DFX_LOG_UNWIND")

	-- lzma defines
	add_defines("ENABLE_MINIDEBUGINFO")

	if is_kind("shared") then
		add_defines(
			"DFX_UNWIND_ERROR",
      		"DFX_ENABLE_TRACE"
		)
		if is_arch("arm64") then
			-- add_defines("ENABLE_PARAMETER")
		end
	elseif is_kind("static") then
		if is_arch("arm64") then
			add_defines("ENABLE_MIXSTACK", "OFFLINE_MIXSTACK")
		end
	end

	-- is_ohos
	add_files("dfx_xz_utils.cpp")

	add_packages("boundscheck", "c_utils", "hilog", "lzma")
	if is_kind("shared") then
		-- add_packages("begetutil")
	end
	add_deps("dfx_trace_dlsym","dfx_hilog","dfx_util")